<template>
	<view class="content">
		<view class="lab">隐身</view>
		<u-cell-item :border-bottom="false" :arrow="false" hover-class="none" title="在首页列表隐藏我">
			<u-switch slot="right-icon" size="40" v-model="checked1"></u-switch>
		</u-cell-item>
		<view class="lab">隐藏距离和在线时间</view>
		<u-cell-item :border-bottom="false" :arrow="false" hover-class="none" title="对他人隐藏我的距离">
			<u-switch slot="right-icon" size="40" v-model="checked2"></u-switch>
		</u-cell-item>
		<u-cell-item :border-bottom="false" :arrow="false" hover-class="none" title="对他人隐藏我的在线时间">
			<u-switch slot="right-icon" size="40" v-model="checked3"></u-switch>
		</u-cell-item>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				checked1: false,
				checked2: false,
				checked3: false,
				checked4: false
			}
		},
		onLoad() {
			var userinfo = this.$store.state.userinfo
			this.checked1 = userinfo.hide_search!=0
			this.checked2 = userinfo.hide_distance!=0
			this.checked3 = userinfo.hide_online_time!=0
		},
		watch:{
			checked1(newval,oldval){
				this.changeSocial('hide_search',newval)
			},
			checked2(newval,oldval){
				this.changeSocial('hide_distance',newval)
			},
			checked3(newval,oldval){
				this.changeSocial('hide_online_time',newval)
			}
		},
		methods: {
			changeSocial(ziduan,newval) {
				var obj = {
					user_id: this.$store.state.userid
				}
				obj[ziduan] = newval ? 1 : 0
				this.$Request({
					url: 'api/user/editInfo',
					data: obj
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		/* #ifndef H5 */
		min-height: 100vh;
		/* #endif */
		/* #ifdef H5 */
		min-height: calc(100vh - 44px);
		/* #endif */
		background-color: #2A2931;

		.lab {
			color: #999;
			padding: 60rpx 30rpx 10rpx;
		}

		/deep/.u-cell_title {
			color: #eee;
		}

		/deep/.u-cell__value {
			color: #CCC;
		}
	}
</style>
